<!DOCTYPE HTML>
<html>
<head>
<include file="Include:meta" />
<title>商务谈判-目的地运营集团数据管理平台</title>
<include file="Include:style" />
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text"><if condition="$project['info_id'] neq NULL">商务跟进</if>项目 > [{$project['project_num']}]{$project['project_name']} > 商务谈判</div>
	</div>
	<div id="content">
		<include file="Include:project_header" />
		<form method="post" name="number_validate" id="password_validate" novalidate="novalidate">
			<div class="form-main">
				<div class="form-title">商务谈判</div>
				<div class="form-table-item">
					<table class="table">
						<tbody>
							<tr class="form-table-header">
								<td>日期</td>
								<td>工作类别</td>
								<td>考察/接待人员</td>
								<td>客户</td>
								<td>资料预览</td>
								<td>沟通备忘录</td>
								<td>添加人(日期)</td>
								<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
								<if condition="$project['tp_status'] neq 1">
								<td width="5%">管理</td>
								</if>
								</if>
							</tr>
							<if condition="$result eq NULL">
							<tr>
								<td class="text-center" <if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1) and ($project['tp_status'] neq 1)">colspan="8"<else/>colspan="7"</if>>暂无相关数据</td>
							</tr>
							</if>
							<foreach name="result" item="vo">
								<tr>
									<td>{$vo['date']}</td>
									<td>{$vo['type']}</td>
									<td>{$vo['bus_users']}</td>
									<td><a href="javascript:;" class="detail" mid="{$vo['ocid']}">{$vo['ouser']}<if condition="$vo['company_name'] neq NULL">【{$vo['company_name']}】</if></a></td>
									<td><if condition="$vo['file_url'] neq NULL">{$vo['file_name']}<a href="{$vo['file_url']}" class="ml5" data-toggle="tooltip" data-placement="right" title="下载"><i class="glyphicon glyphicon-download-alt"></i></a></if></td>
									<td>{$vo['content']}</td>
									<td>{$vo['add_user']}({$vo['add_date']|substr=0,10})</td>
									<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
									<if condition="$project['tp_status'] neq 1">
									<td><a href="javascript:;" mid="{$vo['id']}" action="negotiation_delete" data-toggle="tooltip" data-placement="left" title="删除" class="delete ml5"><i class="glyphicon glyphicon-trash"></i></a></td>
									</if>
									</if>
								</tr>
							</foreach>
						</tbody>
					</table>
				</div>
				<if condition="((((get_permission($qs,NULL,3)) and ($project['add_uid'] eq $login_id)) or (get_permission($qs,NULL,2) and (in_array($project['center_id'],$manage_id))) or (get_permission($qs,NULL,1))) or ($project['director_uid'] eq $login_id) or ($project['manager_uid'] eq $login_id)) and ($project['status'] eq 1)">
				<if condition="$project['tp_status'] neq 1">
				<div class="form-title">商务考察/客户来访信息录入</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>日期</div>
					<div class="input-item">
						<input type="text" name="date" class="form-control Wdate w100 required-text" onclick="WdatePicker()" readonly autocomplete="off">
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>工作类别</div>
					<div class="input-item">
						<span class="checkbox-item">
							<label class="checkbox-inline"><input type="checkbox" name="type[]" value="考察">考察</label>
							<label class="checkbox-inline"><input type="checkbox" name="type[]" value="接待">接待</label>
							<label class="checkbox-inline"><input type="checkbox" name="type[]" value="电话沟通">电话沟通</label>
							<label class="checkbox-inline"><input type="checkbox" name="type[]" value="计划书沟通">计划书沟通</label>
							<label class="checkbox-inline"><input type="checkbox" name="type[]" value="合同沟通">合同沟通</label>
							<label class="checkbox-inline"><input class="book" type="checkbox" name="type[]" value="工作建议书">工作建议书</label>
							<span class="hide pl10 book-cont">
								<if condition="$project_bg['project_uids'] neq NULL">
									<select name="book" class="form-control w100 ml10" autocomplete="off">
									<option value="-10">请选择</option>
									<foreach name="result1" item="vo">
										<option value="{$vo['id']}">{$vo['username']}</option>
									</foreach>
									</select>
								<else/>
									<select name="book" class="form-control w200 ml10" autocomplete="off">
									<option value="-10">请先选择启动表项目人员</option>
									</select>
								</if>
							</span>
							<label class="checkbox-inline ml10"><input class="other" type="checkbox" name="type[]" value="其它">其它</label>
							<input type="text" name="remark_text" class="form-control ml10 hide">
							<span class="error-item">必填项</span>
						</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">考察/接待人员</div>
					<div class="input-item">
						<if condition="$project_bg['project_uids'] neq NULL">
							<button type="button" class="is_all btn">选择人员</button>
						<else/>
							请先选择启动表项目人员
						</if>
						<div class="users-list"></div>
						<input type="hidden" name="uids" class="uids-input" autocomplete="off"/>
						<input type="hidden" name="users" class="users-input" autocomplete="off"/>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>客户</div>
					<div class="input-item">
						<select name="ocid" class="form-control select-add w300 customers" autocomplete="off">
							<option value="-10" selected>请选择</option>
							<foreach name="customers" item="vo">
								<option value="{$vo['id']}">{$vo['username']}<if condition="$vo['company_name'] neq NULL">【{$vo['company_name']}】</if></option>
							</foreach>
						</select>
						<button type="button" class="btn add_cus">添加客户</button>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label">上传相关资料</div>
					<div class="input-item">
						<div class="input-group w250 left">
							<input type="text" name="file_name" class="form-control file-name" placeholder="请上传附件" readonly autocomplete="off">
							<span class="input-group-btn">
								<button class="btn file-submit" type="button">上传</button>
							</span>
						</div>
						<button class="btn file-delete ml5 hide" type="button">删除</button>
						<input type="hidden" name="file_url" class="file-url" autocomplete="off">
						<span class="error-item">文件名必填</span>
					</div>
				</div>
				<div class="form-item">
					<div class="input-label"><span class="asterisk">*</span>沟通备忘录</div>
					<div class="input-item">
						<textarea name="content" class="form-control required-text w500 h150" autocomplete="off"></textarea>
						<span class="error-item">必填项</span>
					</div>
				</div>
				<div class="form-btn-item"><button class="btn submit" type="button">提交</button></div>
				</if>
			</div>
			<if condition="(($project['tp_status'] eq NULL) or ($project['tp_status'] eq -1)) and ($project['gt_status'] eq 1)">
				<div class="form-btn-item"><button class="btn jd_up" pid="{$project['id']}" action="tp_status" status="1" type="button">阶段完成</button></div>
			<elseif condition="($project['tp_status'] eq 1) and (($project['qy_status'] eq -1) or ($project['qy_status'] eq NULL))"/>
				<div class="form-btn-item"><button class="btn jd_down" pid="{$project['id']}" action="tp_status" status="-1" type="button">放弃完成</button></div>
			</if>
			</if>
		</form>
	</div>
</div>
<!--选择用户-->
<div class="modal fade" id="selectuser-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4>选择用户</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body">
				<foreach name="user_list" item="do">
					<div class="department">
						<label><input class="department-checkbox" type="checkbox" autocomplete="off" />{$do['name']}</label>
					</div>
					<ul>
						<foreach name="do['user']" item="uo">
							<li>
								<label><input class="user-checkbox" type="checkbox" value="{$uo['id']}" autocomplete="off" />{$uo['username']}</label>
							</li>
						</foreach>
					</ul>
				</foreach>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn user-affirm">确认</button><button type="button" class="btn btn-default user-cancel" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<!--弹出框-->
<div class="modal fade" id="customeModal">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4>添加客户</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body"></div>
		</div>
	</div>
</div>
<!--客户详情-->
<div id="detailModal" class="modal hide fade">
	<div class="modal-dialog w800">
		<div class="modal-content">
			<div class="modal-header">
				<h4 id="myModalLabel">客户详情</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<div class="modal-body"></div>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript" src="__PUBLIC__/js/user_select.js"></script>
<script>
$(function(){
	$(".jd_up").ajaxModal({"title_text":"完成提示框","body_text":"您确定要完成该阶段吗？","url":"__APP__/Project/stage_ajax","data":{"id":"pid","action":"action","status":"status"}});
	$(".jd_down").ajaxModal({"title_text":"放弃提示框","body_text":"您确定要放弃该阶段吗？","url":"__APP__/Project/stage_ajax","data":{"id":"pid","action":"action","status":"status"}});
	//客户详情
	$(".detail").on("click",function(){
		var mid = $(this).attr("mid");
		$.ajax({
			type:"POST",
			async:false,
			dataType:"json",
			data:{"id":mid},
			url:"__APP__/Project/project_card_detail",
			success:function(data){
				var html = "<table class='table table-bordered'>";
				html+="<tr><td class='side_td' width='10%'>姓名</td><td width='40%'>";
				html+=data.username ? data.username : "";
				html+="</td>";
				html+="<td class='side_td' width='10%'>性别</td><td width='40%'>";
				html+=data.gender ? data.gender : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>公司名称</td><td>";
				html+=data.company_name ? data.company_name : "";
				html+="</td><td class='side_td'>职位</td><td>";
				html+=data.job ? data.job : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>手机号</td><td>";
				html+=data.mobilephone ? data.mobilephone : "";
				html+="</td><td class='side_td'>座机号</td><td>";
				html+=data.telephone ? data.telephone : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>QQ</td><td>";
				html+=data.qq ? data.qq : "";
				html+="</td><td class='side_td'>邮箱</td><td>";
				html+=data.email ? data.email : "";
				html+="</td></tr>";
				html+="<tr><td class='side_td'>地址</td><td colspan='3'>";
				if(data.province){
					html+=data.province+"-"+data.city;
					html+=data.address ? "-"+data.address : "";
				}else{
					html+=data.address ? data.address : "";
				}
				html+="</td></tr>";
				html+="<tr><td class='side_td'>其它信息</td><td colspan='3'>";
				html+=data.remark ? data.remark : "";
				html+="</td></tr>";
				html+="</table>";
				$("#detailModal").find(".modal-body").html(html).end().modal();
			}
		});
	});
	$(".delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Project/stage_ajax","data":{"id":"mid","action":"action"}});
	KindEditor.ready(function(K){
		//上传附件
		var editorFile = K.editor();
		$('.file-submit').on('click',function(){
			var parents = $(this).parents(".input-group");
			editorFile.loadPlugin('insertfile',function(){
				document.cookie="file_name=negotiation";
				document.cookie="file_type=ppt,pptx,pdf,doc,docx,jpg,jpeg,png,xls,xlsx,txt,rar,zip";
				editorFile.plugin.fileDialog({
					clickFn:function(url,title){
						parents.nextAll(".error-item").hide();
						parents.find(".file-name").val(title).prop("readonly",false);
						parents.nextAll(".file-url").val(url);
						parents.nextAll(".file-delete").show();
						editorFile.hideDialog();
					}
				});
			});
		});
	});
	//其它勾选效果
	$(".other").click(function(){
		var $text = $(this).parent().next("[name='remark_text']");
		if($(this).prop("checked")){
			$text.show();
		}else{
			$text.hide().val("");
			$text.next(".error-item").hide();
		}
	});
	$(".book").click(function(){
		var $text = $(this).parent().next("span");
		if($(this).prop("checked")){
			$text.show();
		}else{
			$text.hide().val("");
			$text.next(".error-item").hide();
		}
	});
	//删除附件
	$(".file-delete").click(function(){
		$(this).hide();
		$(this).nextAll(".error-item").hide();
		$(this).nextAll(".file-url").val("");
		$(this).prevAll(".input-group").find(".file-name").val("").prop("readonly",true);
		$(this).parents("tr").find(".required-text").next(".error-item").hide();
	});
	//添加客户
	$("[name='ocid']").on('change',function(){
		if($(this).val()==-10){
			$(".add_cus").show();
		}else{
			$(".add_cus").hide();
		}
	});
	$(".add_cus").click(function(){
		var pid = "{$project['id']}",
			center_id = "{$project['center_id']}";
		$('#customeModal').find('.modal-body').load("__APP__/Project/project_card_add/pid/"+pid+"/way/2/since/2/center_id/"+center_id).end().modal('show');
	});
	//人员选择
	$(".is_all").click(function(){
		$("#selectuser-modal").modal("show");
	});
	//提交验证
	var custome3 = $("#password_validate");
	custome3.find('.submit').on('click',function(){
		var tag = true;
		custome3.find(".checkbox-item").each(function(){
			if($(this).find(":checkbox:checked").length==0){
				$(this).find(".error-item").show();
				tag = false;
			}
		});
		custome3.find(".select-add").each(function(){
			if($(this).val()==-10){
				$(this).nextAll(".error-item").show();
				tag = false;
			}
		});
		custome3.find(".required-text").each(function(){
			var $val = $(this).val();
			if($val==""){
				$(this).nextAll(".error-item").show();
				tag = false;
			}
		});
		custome3.find("[name='remark_text']").each(function(){
			if($(this).is(":visible") && $(this).val()==""){
				$(this).next(".error-item").show();
				tag = false;
			}
		});
		custome3.find(".book-cont").each(function(){
			if($(this).is(":visible") && $(this).find('select').val()==-10){
				$(this).parents('.checkbox-item').find(".error-item").show();
				tag = false;
			}
		});
		custome3.find(".file-name").each(function(){
			var val = $(this).val();
			if((val=="" || /^\s+$/.test(val)) && !$(this).prop("readonly")){
				$(this).parents(".input-group").nextAll(".error-item").show();
				tag = false;
			}
		});
		custome3.find(".file-url").each(function(){
			var val = $(this).val();
			if(val!=""){
				$(this).parents("tr").find(".required-text").each(function(){
					var val2 = $(this).val();
					if(val2=="" || /^\s+$/.test(val2)){
						$(this).next(".error-item").show();
						tag = false;
					}
				});
			}
		});
		if(tag){
			var negotiation_add = 'negotiation_add',
				pid = "{$project['id']}";
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$("[name='number_validate']").serialize()+"&action="+negotiation_add+"&pid="+pid,
				url:"__APP__/Project/stage_ajax",
				success:function(data){
					success_pop(data.status,data.msg);
				}
			});
		}
	});
	//隐藏错误提示
	$(".required-text,[name='remark_text']").focus(function(){
		$(this).nextAll(".error-item").hide();
	});
	$("select.required-selt,select.select-add").change(function(){
		$(this).nextAll(".error-item").hide();
	});
	$(".add_cus").click(function(){
		$(this).siblings(".error-item").hide();
	});
	$(".checkbox-item").on('click',":checkbox",function(){
		$(this).parents(".checkbox-item").find(".error-item").hide();
	});
	$(".file-name").on("focus",function(){
		$(this).parents(".input-group").nextAll(".error-item").hide();
	});
	$("[name='book']").change(function(){
		$(this).parents('.checkbox-item').find(".error-item").hide();
	});
})
</script>
</body>
</html>